package breakthrough;

public class StopWatch
{
	private long startTime;
	
	public StopWatch()
	{
		this.reset();
		this.start();
	}
	
	/**
	 * Starts the timer.
	 */
	public void start()
	{
		this.startTime = System.nanoTime();
	}
	
	/**
	 * Return the elapsed time in nanoseconds.
	 * @return
	 */
	public int getElapsedTime()
	{
		if (startTime == -1)
			return 0;
		else
			return (int) Math.ceil((System.nanoTime() - startTime) / 1000);
	}
	
	/**
	 * Reset the timer.
	 */
	public void reset()
	{
		this.startTime = -1;
	}
}
